/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package lab6.lab;

import java.util.ArrayList;
import java.util.Scanner;

/**
 *
 * @author c0909h1169
 */
public class ComputerList {
    ArrayList computerList;
    public void add2List()
    {
        int n;
        Computer[] computer;
        Scanner scan = new Scanner(System.in);
        System.out.println("Enter number of computer: ");
        n = Integer.parseInt(scan.nextLine());
        computerList = new ArrayList();
        for(int i = 0;i<n;i++)
        {
            computer = new Computer[n];
            System.out.println("Information of Computer "+(i+1));
            System.out.print("Enter computer ID: ");
            int id = scan.nextInt();
            System.out.print("\nEnter computer Name: ");
            String name = scan.next();
            System.out.print("\nEnter computer price:");
            Double price = new Double(scan.nextDouble());
            computer[i] = new Computer(id, name, price); 
             //add to array list
            computerList.add(computer[i]);

        }
        for(int i =0;i<n;i++)
        {
            System.out.println(computerList.get(i));
        }
    }

}
